use Test;
use Rollout qw/slurp_file file_install/;
use strict;

BEGIN { plan tests => 8 }

unlink "/tmp/hosts";
ok(file_install("/tmp/hosts", "/etc/hosts"));
ok(slurp_file("/tmp/hosts") eq slurp_file("/etc/hosts"));
ok(!file_install(-src=>"/etc/hosts", -dst=>"/tmp/hosts"));
ok(file_install({ -src=>"/etc/hosts", -dst=>"/tmp/hosts", -eval=>sub{s/127\.0\.0\.1/X.X.X.X/g}, -mode=>0600 }));
ok(((stat "/tmp/hosts")[2] & 07777) == 0600);
ok(slurp_file("/tmp/hosts", -eval=>"s/X.X.X.X/127.0.0.1/g") eq slurp_file("/etc/hosts"));
unlink "/tmp/iwade";
ok(file_install("/tmp/iwade", "http://members.optusnet.com.au/iwade/index.html", { filter=>[ 'tr', '[a-z]', '[A-Z]' ] }));
ok(slurp_file("/tmp/iwade") =~ /ETERNITY/);
